package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.introduction.domain.ServiceIntroduction;
import com.ruoyi.introduction.service.IServiceIntroductionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务介绍Controller
 * 
 * @author ruoyi
 * @date 2024-01-19
 */
@RestController
@RequestMapping("/frist/introduction")
public class ServiceIntroductionController extends BaseController
{
    @Autowired
    private IServiceIntroductionService serviceIntroductionService;

    /**
     * 查询服务介绍列表
     */
    @PreAuthorize("@ss.hasPermi('frist:introduction:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceIntroduction serviceIntroduction)
    {
        startPage();
        List<ServiceIntroduction> list = serviceIntroductionService.selectList(serviceIntroduction);
        return getDataTable(list);
    }

    /**
     * 导出服务介绍列表
     */
    @PreAuthorize("@ss.hasPermi('frist:introduction:export')")
    @Log(title = "服务介绍", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceIntroduction serviceIntroduction)
    {
        List<ServiceIntroduction> list = serviceIntroductionService.selectList(serviceIntroduction);
        ExcelUtil<ServiceIntroduction> util = new ExcelUtil<ServiceIntroduction>(ServiceIntroduction.class);
        util.exportExcel(response, list, "服务介绍数据");
    }

    /**
     * 获取服务介绍详细信息
     */
    @PreAuthorize("@ss.hasPermi('frist:introduction:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(serviceIntroductionService.selectById(id));
    }

    /**
     * 新增服务介绍
     */
    @PreAuthorize("@ss.hasPermi('frist:introduction:add')")
    @Log(title = "服务介绍", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceIntroduction serviceIntroduction)
    {
        return toAjax(serviceIntroductionService.insert(serviceIntroduction));
    }

    /**
     * 修改服务介绍
     */
    @PreAuthorize("@ss.hasPermi('frist:introduction:edit')")
    @Log(title = "服务介绍", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceIntroduction serviceIntroduction)
    {
        return toAjax(serviceIntroductionService.update(serviceIntroduction));
    }

    /**
     * 删除服务介绍
     */
    @PreAuthorize("@ss.hasPermi('frist:introduction:remove')")
    @Log(title = "服务介绍", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(serviceIntroductionService.deleteByIds(ids));
    }
}
